package com.elm.service.impl;

import com.elm.dao.CartDao;
import com.elm.entity.Cart;
import com.elm.service.CartService;

import java.sql.SQLException;
import java.util.List;

public class CartServiceImpl implements CartService {
    private final CartDao cartDao;
    public CartServiceImpl() {
        this.cartDao = new CartDao();
    }


    @Override
    public List<Cart> getCartListByUserId(String userId) throws SQLException {
        return cartDao.getCartListByUserId(userId);
    }

    @Override
    public List<Cart> getCartListByUserIdAndBusinessId(String userId, int businessId) throws SQLException {
        return cartDao.getCartListByUserIdAndBusinessId(userId, businessId);
    }

    @Override
    public int saveCart(Cart cart) throws SQLException {
        cart.setQuantity(1);
        return cartDao.saveCart(cart);
    }

    @Override
    public int updateCart(Cart cart) {
        return cartDao.updateCart(cart);
    }

    @Override
    public int removeCart(Cart cart) throws SQLException {
        return cartDao.removeCart(cart);
    }
}